<?php
	require_once("tpl/header.php");
	$vid = $_REQUEST['vid'];
	
	$sql = "select * from videos where vid=$vid";
	$res = mysqli_query($link,$sql);
	$video = mysqli_fetch_assoc($res);
?>
<script type="text/javascript" src="assets/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="assets/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" src="assets/ueditor/lang/zh-cn/zh-cn.js"></script>
<script src="js/jquery-2.2.0.min.js"></script>
<div class="container">

    <div class="row row-offcanvas row-offcanvas-right">

        <div class="col-xs-12 col-sm-12">


            <div class="row box">
                <div class="col-lg-12 text-center">
                    <video src="uploads/video/<?php echo $video['address'];?>"></video>

                    <h1 class="brand-name"><?php echo $video['videoname'];  ?></h1>

                </div>


            </div>
            <!--/row-->
            <div class="row box">

                <div class="col-lg-12">
                    <h2 class="intro-text text-center">内容简介

                    </h2>
					<div >
						<?php echo $video['intro'];?>
					</div>

                </div>		
				
            </div>
			
			<div class="row box">

                <div class="col-lg-12">
                    <h2 class="intro-text text-center">评论

                    </h2>
					<?php
						if(isset($_SESSION['user'])){
					?>
					<div >
					<form id="comment">
						<input type="hidden" name="vid" 
						value="<?php echo $video['vid']; ?>"/>
						<textarea id="content" name="content">
						</textarea>
						<a id="btn-comment">提交</a>
					</form>
					</div>
					<?php
						}
					?>
					
					
                </div>		
				
            </div>
        </div>
        <!--/.col-xs-12.col-sm-12-->

       
    </div>
    <!--/row-->

    

</div>
<!--/.container-->
<script>

UE.getEditor('content',{initialFrameWidth:600,initialFrameHeight:200})

</script>
<script src="js/jquery-2.2.0.min.js"></script>
<script type="text/javascript">
	$("#btn-comment").click(function(){
		// url：将请求提交到哪里去
		// data：请求参数
		// type：请求方式，例如GET或POST等
		// dataType：服务器端响应的数据类型，取值可以是json、text、xml等，取决于服务器端响应时的响应头中的Content-Type
		// success：响应成功时(Http响应码是200)的回调(callback)函数，函数中的参数就是服务器端响应的JSON数据形成的JSON对象
        // error: 响应失败时的回调函数(Http响应码不是200的情况)
		$.ajax({
			"url":"personal/docomment.php",
			"data":$("#comment").serialize(),//序列化表单值："username=Hello&password=123456"
			"type":"post",
			"dataType":"json",
			"success":function(obj) {
				
				if (obj == 0) {
					alert("评论失败，请联系管理员！");
				} else {
					alert("评论成功！");
					
				}
			},
            "error":function(obj) {
                }
		});
	});

</script>
 <?php
	require_once('tpl/footer.php');
 ?>